;(function(window) {
    var ndeduCommon = {},
        $user = $('.user-img'),
        $userImg = $user.find('img'),
        $longinOut = $('.login-out');
    //侧边意见按钮翻转
    ndeduCommon.btnContact = function() {
        //判断IE9及以下
        if (navigator.appName == "Microsoft Internet Explorer" && parseInt(navigator.appVersion.split(";")[1].replace(/[ ]/g, "").replace("MSIE", "")) <= 9) {
            var _btnContact = $('.btn-contact-wrap'),
                _front = _btnContact.find('.front'),
                _back = _btnContact.find('.back');

            _back.hide();

            _btnContact.hover(function() {
                _front.fadeOut();
                _back.fadeIn();
            }, function() {
                _front.fadeIn();
                _back.fadeOut();
            })
        }
    },
    //导航栏激活态
    ndeduCommon.setNav = function() {
        var $nav = $('.nav-list'),
            $navList = $nav.find('.nav-item');
        var queryObject = getQueryObject();
        $navList.each(function() {
            var title = $(this).attr('title');
            if(decodeURIComponent(queryObject.name) == title) {
                $(this).addClass('active');
            }
        });
    // $navList.eq(i).
    },
    //头部搜索按钮
    ndeduCommon.search = function() {
        $('.btn-search').on('click', function() {
            
            var keyWord = $(this).siblings('input').val();
            if (keyWord) {
                window.location.href = '/article/search?keyword=' + encodeURIComponent(keyWord);
            }
        });
        $('.search-wrap input').on('keydown', function(e) {
            if ($(this).val() && e.keyCode === 13) {
                $('.btn-search').trigger('click');
            }
        });
    },
    ndeduCommon.goTop = function() {
        $(window).scroll(function() {
            $(window).scrollTop() > 600 ? $(".gotop").addClass("show") : $(".gotop").removeClass("show")
        }),
        $(".gotop").click(function() {
            return $("body,html").animate({
                scrollTop: 0
            }, 700),
            !1
        })
    },
    ndeduCommon.isLogin = function() {
        // var udedu = ndeduCommon.getCookie('ndedu');
        // //当前登录
        // if(udedu=="true"){
        //     ndeduCommon.getUserInfo();
        //     //当前已登录，可以获取mactoken签名头，用户信息等操作
        // }else{
        //     //自定义重新登录或其他
        //    top.location.href='/login.shtml';
        // }
        // 退出登录；
        $user.on('click', function() {
            $longinOut.toggle();
            $(this).toggleClass('active');
        });
    },

    window.ndeduCommon = ndeduCommon;
})(window);
$(function() {
    ndeduCommon.btnContact();
    ndeduCommon.setNav();
    ndeduCommon.search();
    ndeduCommon.isLogin();
    ndeduCommon.goTop()
// ndeduCommon.loginOut();
});
/*解决ie不支持placeholder*/
(function($) {
    $.fn.placeholder = function(options) {
        var opts = $.extend({}, $.fn.placeholder.defaults, options);
        var isIE = document.all ? true : false;
        return this.each(function() {
            var _this = this,
                placeholderValue = _this.getAttribute("placeholder"); //缓存默认的placeholder值
            if (isIE) {
                _this.setAttribute("value", placeholderValue);
                _this.onfocus = function() {
                    $.trim(_this.value) == placeholderValue ? _this.value = "" : '';
                };
                _this.onblur = function() {
                    $.trim(_this.value) == "" ? _this.value = placeholderValue : '';
                };
            }
        });
    };
})(jQuery);
$('.search-wrap').find('input').placeholder();
